package com.kalua.list.harvester.parser;

import java.util.zip.CRC32;

import com.kalua.list.domainmodel.NumericId;
import com.kalua.list.domainmodel.TextIdentifier;

public class ProductIdGenerationUtils {
	
	private static final String SEPERATOR_CHARS = " |-| ";
	
	private ProductIdGenerationUtils() {}
	
	public static NumericId generateId(	TextIdentifier retailerId, 
															TextIdentifier retailerIssuedId) {
		NumericId result;
		
		CRC32 checksumCalculator = new CRC32();
		checksumCalculator.update(retailerId.getValue().getBytes());
		checksumCalculator.update(SEPERATOR_CHARS.getBytes());
		checksumCalculator.update(retailerIssuedId.getValue().getBytes());
		
		result = new NumericId(checksumCalculator.getValue());
		
		return result;
	}
}